package com.mfs.proxy.client.transfer.http.request;

import com.mfs.common.constant.Constant;

import java.io.UnsupportedEncodingException;

/**
 * Http 请求行
 *
 * @author mfs
 * @date 2023/7/10 22:31
 **/
public class HttpRequestLine {
    private String method;
    private String target;
    private String version;

    public byte[] getBytes() {
        try {
            return (method + Constant.BLANK_STRING + target + Constant.BLANK_STRING + version + "\r\n").getBytes("ascii");
        } catch (UnsupportedEncodingException e) {
        }
        return null;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    @Override
    public String toString() {
        return method + Constant.BLANK_STRING + target + Constant.BLANK_STRING + version;
    }
}
